<template>
  <div>
    <!-- 其他内容 -->
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
const props = defineProps({
  name: { type: String, default: "" },
});

const imagePath = ref('');

// 使用动态 import
const loadImage = async () => {
  // const imageName = await getImageName();
  const path = `/src/assets/svg/${props.name}.svg`;
  imagePath.value = await import(path);
}

// 初始化加载图片
onMounted(() => {
  loadImage(props.name);
});

// 使用 h 函数渲染 img 标签
const renderImage = () => {
  if (imagePath.value.default) {
    return h('img', {
      src: imagePath.value.default,
      alt: 'Dynamic Image',
    });
  }
  return null;
};

defineExpose({ renderImage });
</script>